﻿Imports System.Data.SqlClient

Public Class frmFonacotNuevos
    Dim bITACORA As New clsActividad
    Private Sub frmFonacotNuevos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.CheckBox1.Checked = False

        Me.dgCargos.Rows.Clear()

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim cmdBuscar As New SqlCommand
        cmdBuscar.Connection = cnConn
        cmdBuscar.CommandText = "SELECT B.IDEmpleado,B.fecha,B.motivo,original,nuevo,B.capturo,NombreCompleto From InfonavitFonacot B INNER JOIN Empleados E ON b.idempleado=e.idempleado " & _
        " WHERE B.reportado='No' and tipo='FONACOT' order by fecha"

        Dim rdBuscar As SqlDataReader

        cnConn.Open()
        rdBuscar = cmdBuscar.ExecuteReader
        Dim f As Date

        Do While rdBuscar.Read()
            f = rdBuscar("fecha")
            Me.dgCargos.Rows.Add(rdBuscar("NombreCompleto"), f.Day & "/" & f.Month & "/" & f.Year, rdBuscar("original"), rdBuscar("nuevo"), rdBuscar("motivo"), rdBuscar("capturo"))
        Loop
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub btnAbrir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbrir.Click
        ToExcel(Me.dgCargos, "Relacion de correcciones de fonacot al " & Now())
    End Sub

    Private Sub RadButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton2.Click
        If Me.CheckBox1.Checked = True Then
            Call SetSqlCitra("Update InfonavitFonacot set reportado='Si' where reportado='No' and tipo='FONACOT'")
            bITACORA.RegistraActividad("Revisó las notificaciones de nuevas correcciones de fonacot")
            Me.Close()
        Else
            Me.Close()
        End If
    End Sub
End Class